#ifndef _MY_UTIL_HPP
#define _MY_UTIL_HPP

#include "CtrlLib/CtrlLib.h"

using namespace Upp;

inline String AsHexString(const String& a)           
{ 
    String s; 
    for(byte c : a) 
    {
        s << FormatIntHexUpper(c, 2) << " "; 
    }
    return s; 
}

struct MyTime;

MyTime MyGetSysTime();
MyTime GetUtcTime();

struct MyTime: Time
{
    int milliseconds;

	MyTime()                   { *this = MyGetSysTime();}
	MyTime(const Nuller&)      {*this = MyGetSysTime();}
	MyTime(int y, int m, int d, int h = 0, int n = 0, int s = 0, int ms = 0)
        { day = d; month = m; year = y; hour = h; minute = n; second = s; milliseconds = ms; }
    
    double Get() {
        return Date::Get() * (int64)24 * 3600 + hour * 3600 + minute * 60 + second + milliseconds / 1000.0;
    }

};



inline double operator-(MyTime a, MyTime b)
{
    return a.Get() - b.Get();
}

String Format(MyTime time);

inline String AsString(const MyTime& time) { return Format(time); }

#endif
